import request from '@/config/axios'

// 短链卡片 VO
export interface LinkCardVO {
  title: string // 标题
  description: string // 描述
  icon: string // 图标
  url: string // 跳转URL
  /** 生成二维码 */
  getLinkCardQRCode: (id: string) => Promise<Blob>
}

// 短链卡片 API
export const LinkCardApi = {

  /** 生成二维码 */
  getLinkCardQRCode: (id: string) => {
    return request.download({
      url: '/system/link-card/qrcode',
      params: { id }
    })
  },

  // 查询短链卡片分页
  getLinkCardPage: async (params: any) => {
    return await request.get({ url: `/system/link-card/page`, params })
  },

  // 查询短链卡片详情
  getLinkCard: async (id: number) => {
    return await request.get({ url: `/system/link-card/get?id=` + id })
  },

  // 新增短链卡片
  createLinkCard: async (data: LinkCardVO) => {
    return await request.post({ url: `/system/link-card/create`, data })
  },

  // 修改短链卡片
  updateLinkCard: async (data: LinkCardVO) => {
    return await request.put({ url: `/system/link-card/update`, data })
  },

  // 删除短链卡片
  deleteLinkCard: async (id: number) => {
    return await request.delete({ url: `/system/link-card/delete?id=` + id })
  },

  // 导出短链卡片 Excel
  exportLinkCard: async (params) => {
    return await request.download({ url: `/system/link-card/export-excel`, params })
  },
}
